<?php
session_start();
require_once 'php_includes.php';

//Make sure logged in
checkLogin();
	
///////////////////////////////////
//This is only for manager only pages
sqlConnect();
//make sure it is a manager logged on
checkManager();
?>

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Strict//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-strict.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
  <head>
    <title>Payroll and Timesheet Management Website</title>
    <link rel="stylesheet" type="text/css" href="styles.css"/>
  </head>
  <body>
  <?php writeHeader(); ?>
		<p>
	<span class="pageheader">Employee timesheet reports</span><br/>
	<i><small>Click on an employee to view past submitted timesheets</small></i><br/>
	</p>
	
	<?php
require_once 'php_includes.php';


//Establishes connection to the database
sqlConnect();
$con=sqlConnect();
mysql_select_db("titans", $con);

$SQLstring="SELECT * FROM Employee";
$QueryResult=sqlQuery($SQLstring);
	echo"<table class='full'>";
	echo"<th></th><th>ID</th><th>Employee Name</th><th>Title</th><th>Department</th><th>Records</th></tr>";
	$Row = mysql_fetch_row($QueryResult);
	do
	{
		$var1=0;
		$var2=0;
		$var3=0;
		$fName=$Row[3];
		$lName=$Row[4];
		$space=' ';


		$var1 = ceil(mysql_num_rows(sqlQuery('select EmployeeID FROM CurrentTime WHERE EmployeeID='. $Row[0])));
		$var2 = ceil(mysql_num_rows(sqlQuery('select EmployeeID FROM PastWeeklyTime WHERE EmployeeID='. $Row[0])));
		$var3 = ceil(mysql_num_rows(sqlQuery('select EmployeeID FROM PendingApproval WHERE EmployeeID='. $Row[0])));
		$sum=$var1+$var2 +$var3;
		
		echo"<tr><td class='view'><form action='previoustime.html' method='post'><div><input type='submit' value='View' class='button' /></div></td><td name='userID' class='id'>{$Row[0]}</td></form><td name='userName' class='record'>{$fName}{$space}{$lName}  </td><td name='userTitle' class='record'>{$Row[5]}</td><td name='userDept' class='record'>{$Row[7]}</td><td name='userRec' class='record'>{$sum}</td></tr>";
		$Row=mysql_fetch_row($QueryResult);
	}while($Row);
	
sqlExit();
	?>
	  </body>
</html>